﻿<%@ Page Title="您可能认识的朋友" Language="C#" MasterPageFile="~/member/mMenber.master" AutoEventWireup="true" CodeBehind="pfriendsRel.aspx.cs" Inherits="map.member.pfriendsRel" %>

<%@ Register Assembly="RuleCode.Common" Namespace="RuleCode.Controls" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head2" runat="server">
      <link href="../outstyle.css" rel="stylesheet" type="text/css" />
      <link href="../Stylesheet1.css" rel="stylesheet" type="text/css" />
      <script src="../js/dropdowncontent.js" type="text/javascript"></script>
    <style type ="text/css">
        .InfoheaderDiv
        {
            width:90%;
            height:30px;
            background-color:#FEFFCF;
            vertical-align:middle;
            text-align:center;
            padding-top:12px;
        }
        .MainDiv a
        {
           color:Blue;
           width:1000px; 
        }
        .InfoheaderDivHr
        {
            width:90%;
            margin-top:5px;
            margin-bottom :5px;
            text-align:left;
        }
        .DataListDiv
        {
            width:90%;
            background-color:#F0F5F8;
            border:solid 1px lightGray;
        }
        .DataListTable
        {
            margin:4px 0px 4px 0px;
            border:solid 1px lightGray;
            width:100%;
            background-color:White ;
        }
        .DataListTable li
        {
            list-style-type:none;
        }
        .hiddenObject
        {
            visibility:hidden ;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder3" runat="server">
      <div class ="MainDiv">
        <div  class ="InfoheaderDiv">
           <span>我们会根据你的个人资料对搜索结果进行排序，完善你的 <a href ="pinfo.aspx" >学校资料</a> 将会看到更准确的搜索结果。</span> 
        </div>
        <hr  class ="InfoheaderDivHr"/>
        <div class ="DataListDiv">
            <div style =" margin:5px 5px 5px 5px;">
                <asp:UpdatePanel ID="MainUpdatePanel"  runat="server">
                     <ContentTemplate>
                         <asp:DataList ID="MainDataList" Width="100%" runat="server">
                            <ItemTemplate>
                                <table class ="DataListTable">
                                     <tr>
                                        <td style =" width:70px">
                                            <a href ="#">
                                                <img alt ="" style =" width:60px; height :50px; border:none"  src ='<%#(Eval("cbimgpath").ToString()=="")?"../img/userdefaultimg.gif":Eval("cbimgpath") %>'/>
                                            </a>
                                        </td>
                                        <td style =" text-align:left ">
                                            <%# GetUlHtml (Eval("cbname").ToString(),Eval("ColleageName").ToString(),Eval("JuniorSchoolName").ToString(),Eval("SeniorSchoolName").ToString(),Eval("LastEmployeeName").ToString() )%>
                                        </td>
                                        <td style =" width:20%; text-align :left ;">
                                             <ul>
                                                <li>
                                                    <a href ="#" onclick="showaddNewFriends(this);">加为好友</a>
                                                    <input  value='<%#(Eval("cbimgpath").ToString()=="")?"../img/userdefaultimg.gif":Eval("cbimgpath") %>' type ="hidden" />
                                                    <input value='<%#Eval("cbuserid").ToString() %>' type ="hidden"/>
                                                    <input value='<%#Eval("cbname").ToString() %>' type ="hidden"/>
                                                </li>
                                             </ul>
                                        </td>
                                     </tr>
                                </table>
                            </ItemTemplate>
                         </asp:DataList>
                         <div style =" background-color:White ;">
                         <cc1:WebPager ID="MainWebPager"  PageSize ="10" OnPageIndexChanged ="MainWebPager_PageIndexChanged"
                            ControlToPaginate ="MainDataList" PagerStyle="NumericPages" runat="server" />
                         <asp:Button value="刷新" ID="UpdatePageButton" CssClass="hiddenObject " runat ="server" OnClick ="UpdatePageButton_Click"/>
                         </div>
                     </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </div>
      </div>
      
      <%--添加好友--%>
        <div class="sample_popup" id="popup" style=" position:absolute ; height:200px; width :400px; z-index :2;  display :none; ">
            <div class="menu_form_header" id="popup_drag">
                <table>
                    <tr>
                        <td>
                            添加好友：
                        </td>
                        <td>
                            <img alt="" class="menu_form_exit" onclick="document.getElementById('popup_exit').click()" src="../img/closes.png" />
                        </td>
                    </tr>
                </table>
            </div>
            <div class="menu_form_body">    
                <div style =" width :100%;">
                    <table width="100%">
                        <tr>
                            <td style =" width:200px;">
                                <table width="200px">
                                    <tr>
                                        <td colspan="2">
                                            您将添加 <a id="NewFriendIdAnchor" style=" text-decoration:underline" href ="#"></a>为好友
                                            <input type ="hidden"  value="" id="NewFriendIdHiddenInput" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td  >
                                            <span style =" text-align :left ">选择分组：</span>
                                        </td>
                                        <td>
                                            <select id="NewFriendGroupSelect">
                                                <option value ="" selected ="true">请选择分组</option>
                                            </select>
                                        </td>
                                    </tr>                        
                                    <tr>
                                        <td >
                                            <span style =" text-align :left ">备注(可选)：</span>
                                        </td>
                                        <td style =" text-align:left">
                                            <input id="FriendNickText" type="text" style="width: 100px" />
                                        </td>
                                    </tr>
                                </table>                                         
                            </td>
                            <td style =" width:100px; text-align:center;">
                                <img  style =" padding-top:10px; width:80px; height :80px;" id="NewFriendImg"/>
                            </td>
                        </tr>
                    </table>                             
                </div>
                <div style="text-align: center;  width: 100%">
                    <input id="AddButton" type="button" value="增加" onclick=" if( addFriend()==true) document.getElementById('popup_exit').click();" />
                    <input id="popup_exit" type="button" value="取消"  />
                </div>
                <%-- <input id="GroupIdHidden" type="hidden"  />--%>
            </div>
        </div>
      <div id="maskDiv" style =" position :absolute ;top:0px; left :0px;   visibility :hidden ; background-color :#666;  z-index :1;"></div>
    
    <script type ="text/javascript">
        //添加好友
        function showaddNewFriends(thisObj) {
            var thisObjHiddenInputs = thisObj.parentNode.getElementsByTagName("input");
            var friendImgPath = thisObjHiddenInputs[0].value;
            var friendsId = thisObjHiddenInputs[1].value;
            var friendsName = thisObjHiddenInputs[2].value;
            var currentUserId = AjaxFunction.GetCurrentUserId().value;
            if (currentUserId != null && currentUserId != "") {
                var mtop = parseInt(250) + "px";
                var mleft = parseInt(350) + "px";
                initAddFriendDiv(friendsId, friendsName, friendImgPath, currentUserId);
                popup_show('popup', 'popup_drag', 'popup_exit', mtop, mleft, true, 'maskDiv', 50);
            }
            else {
                clearAddFriendDiv();
                alert("对不起，您还未登录，请先登录！");
                window.location.href = "../member/login.aspx";
            }
        }
        function clearAddFriendDiv() {
            document.getElementById("NewFriendImg").src = "";
            document.getElementById("NewFriendIdAnchor").innerHTML = "";
            document.getElementById("NewFriendIdHiddenInput").value = "";
            document.getElementById("FriendNickText").value = "";
            var friendGroupSelect = document.getElementById("NewFriendGroupSelect");
            friendGroupSelect.innerHTML = "";
            var newOptionEle = document.createElement("option");
            newOptionEle.innerHTML = "请选择分组";
            newOptionEle.value = "";
            newOptionEle.selected = "true";
            friendGroupSelect.appendChild(newOptionEle);
        }
        function initAddFriendDiv(friendsId, friendsName, friendImgPath, currentUserid) {
            document.getElementById("NewFriendImg").src = friendImgPath;
            document.getElementById("NewFriendIdAnchor").innerHTML = friendsName;
            document.getElementById("NewFriendIdHiddenInput").value = friendsId;
            document.getElementById("FriendNickText").value = friendsName;
            var friendGroupSelect = document.getElementById("NewFriendGroupSelect");
            friendGroupSelect.innerHTML = "";
            var newOptionEle = document.createElement("option");
            var allGroupResult = AjaxFunction.GetCurrentGroupList();
            if (allGroupResult.value != null && allGroupResult.value != "") {
                var allGroupList = eval(allGroupResult.value);
                for (var i = 0; i < allGroupList.length; i++) {
                    newOptionEle = document.createElement("option");
                    if (i == 0)
                        newOptionEle.selected = "true";
                    newOptionEle.value = allGroupList[i].id;
                    newOptionEle.innerHTML = allGroupList[i].name;
                    friendGroupSelect.appendChild(newOptionEle);
                }
            }
        }
        function addFriend() {
            var friendsName = document.getElementById("NewFriendIdAnchor").innerHTML;
            var friendsId = document.getElementById("NewFriendIdHiddenInput").value;
            var friendsNick = document.getElementById("FriendNickText").value;
            var friendGroupSelect = document.getElementById("NewFriendGroupSelect");
            if (friendsNick.replace(/\s/g, "") == "") {
                alert("对不起，好友昵称不能为空！");
                return false;
            }
            var friendsGroupId = friendGroupSelect[friendGroupSelect.selectedIndex].value;
            var result = AjaxFunction.AddNewFriend(friendsGroupId, friendsId, friendsNick);
            if (result.value != null && result.value == "") {
                document.getElementById("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder3_UpdatePageButton").click();
                alert("添加成功");
                return true;
            }
            else {
                if (result.value == null)
                    alert("添加失败");
                else
                    alert(result.value);
                return false;
            }
        }
    </script>
      
</asp:Content>


